package com.hk.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hk.constant.CacheConstants;
import com.hk.constant.HttpStatus;
import com.hk.core.PageResult;
import com.hk.domain.DictData;
import com.hk.mapper.DictDataMapper;
import com.hk.service.DictDataService;
import org.springframework.stereotype.Service;

@Service
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements DictDataService {

    @Override
    public PageResult dictDatalist(Integer pageNum, Integer pageSize, String dictType) {
        Page<DictData> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<DictData> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DictData::getDictType,dictType);
        page =  super.page(page, wrapper);
        PageResult pageResult = new PageResult();
        pageResult.setCode(HttpStatus.SUCCESS);
        pageResult.setMsg(CacheConstants.LOGIN_SUCCESS1);
        pageResult.setRows(page.getRecords());
        pageResult.setTotal(Integer.parseInt(page.getTotal()+""));
        return pageResult;
    }
}
